package com.sam4cloud.common.core.model.supers;

import org.springframework.beans.BeanUtils;

import java.io.Serializable;

/**
 * <p>
 * 普通实体父类
 * </p>
 */
public class Convert implements Serializable {

    /**
     * 获取自动转换后的JavaBean对象
     *
     * @param clazz
     * @return <T>
     */
    public <T> T convert(Class<T> clazz) {
        T target = null;
        try {
            target = clazz.newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            return null;
        }
        BeanUtils.copyProperties(this, target);
        return target;
    }
}
